#include <iostream>
#include <fstream>
#include <cassert>
#include "SegmentedRealizableSpadjor.h"
#include "YinSet.h"
#include "YinFab.h"
#include <string.h>
using std::cout;
using std::endl;
using std::ifstream;
using std::ofstream;
const int Dim = 2;
const int Order = 2;
const Real tol = 1e-8;

using namespace Chombo;

int main(int argc, char const *argv[])
{
  using rVec = Vec<Real, Dim>;
  const int GridSize = 15;
  const rVec GridOrigin = {-1.0,-1.0};
  const Real dx = 0.5;
  std::cout<<"-----------------------YinFab Test1-----------------------"<<std::endl;
  std::cout<<"//Use a grid to act on the Panda YinSet."<<std::endl;
  std::cout<<"Grid Size: "<<GridSize<<" by "<<GridSize<<std::endl;
  std::cout<<"Grid Origin: "<<GridOrigin<<std::endl;
  std::cout<<"Grid Width: "<<dx<<std::endl;

  ifstream input1("data1/Panda.dat", std::ios::binary);
  assert(input1);
  YinSet<Dim, Order> *panda;
  panda = new YinSet<Dim, Order>(input1, tol);
  Box b1(IntVect::Zero, IntVect::Unit * (GridSize-1));
  YinFab<Order> yf1(b1);
  yf1.setOrigin(GridOrigin);
  yf1.setDx(dx);
  yf1.setTol(tol);
  yf1.setYinSet(panda);
  yf1.generateYinFab();
  yf1.dumpAll("dataTestYinFab1/cord");

  return 0;
}
